﻿
CREATE PROCEDURE [dbo].[fares_FiltreazaRaportArticoleComanda] 
	@filtruPart varchar(8000),
	@filtruArt varchar(8000),
	@data1 datetime,
	@data2 datetime,
	@CodUnitate smallint
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	SELECT * FROM [fares_viewSumeCategorii] WHERE 
	(LEN(LTRIM(RTRIM(@filtruArt)))=0 OR (IDArticol IN (SELECT fart.value FROM dbo.SplitIntParameters(@filtruArt,',') fart))) AND
    (LEN(LTRIM(RTRIM(@filtruPart)))=0 OR (IDPartener IN (SELECT fart.value FROM dbo.SplitBigIntParameters(@filtruPart,',') fart))) AND
	[DataDoc]>=@data1 AND [DataDoc]<= @data2 AND CodUnitate = @CodUnitate
	 ORDER BY [DataDoc]

END